package com.zch.client.spring.mqtt.dto;

import com.zch.client.spring.mqtt.listener.AbstractMqttConsumerListener;
import lombok.Data;

/**
 * 消费者主动订阅某个topic
 */
@Data
public class MqttSubscribeRequest {
    // 如果messageListener 不为空 则 这里的消息messageArrived 优先级更高 它会覆盖 MqttCallback 中的 messageArrived 回调
    private AbstractMqttConsumerListener messageListener;

    private String topic;
    // 0~2
    private int qos;


    public int getQos() {
        if(qos >=2){
            return 2;
        }
        if(qos <=0){
            return 0;
        }
        return qos;
    }
}
